<!doctype HTML>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<body id="focus" contenteditable>
<p id="anchor">This is a testcase for <a href="https://bugs.webkit.org/show_bug.cgi?id=7152">webkit issue 7152</a>.
Adding visible candidates after tables, at [table, numberOfChildren], threw
LayoutView::setSelection for a loop because it assumed the end of a selection
would be inside an atomic node.</p>
<div id="log"></div>
<table id="sample" border="1" ><tr><td>This should be selected.</td></tr><tr><td>This should be selected.</td></tr></table>
<script>
test(function() {
    document.execCommand('selectAll');

    var selection = window.getSelection();
    var anchor = document.getElementById('anchor').firstChild;
    var focus = document.getElementById('focus');
    assert_equals(selection.anchorNode, anchor, 'anchorNode');
    assert_equals(selection.anchorOffset, 0, 'anchorOffset');
    assert_equals(selection.focusNode, focus, 'focusNode');
    assert_equals(selection.focusOffset, 6, 'focusOffset');
});
</script>
